﻿using SMARTMobile.WinPhone.Models;

namespace SMARTMobile.Models.UI
{
    public class ProvinceModel : BaseModel<ProvinceModel>
    {
        private string _code;
        private string _name;

        public ProvinceModel()
        {
            this.Code = "0";
            this.Name = "Chon Tinh/Thanh Pho";
        }

        public ProvinceModel(SqlProvince province)
        {
            this.Code = province.ProvinceCode;
            this.Name = province.ProvinceName;
        }

        public string Code
        {
            get { return this._code; }
            set
            {
                this._code = value;
                base.RaisePropertyChanged(me => me.Code);
            }
        }

        public string Name
        {
            get { return this._name; }
            set
            {
                this._name = value;
                base.RaisePropertyChanged(me => me.Name);
            }
        }

        public override int GetHashCode()
        {
            int hashCode = 0;

            unchecked
            {
                hashCode += string.IsNullOrEmpty(this.Code) ? 0 : this.Code.GetHashCode();
                hashCode += string.IsNullOrEmpty(this.Name) ? 0 : this.Name.GetHashCode();
            }

            return hashCode;
        }

        public override bool Equals(object obj)
        {
            ProvinceModel other = obj as ProvinceModel;
            if (other == null)
                return false;

            return other.Code == this.Code;
        }

        public override string ToString()
        {
            return this.Name;
        }
    }
}
